package com.androidproject;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.androidproject.modele.Game;

public class LineAdapterClassement extends BaseAdapter {

	private LayoutInflater lInflater;
	private List<Game> listGame;
	
	public LineAdapterClassement(Context context, List<Game> games) {
		lInflater = LayoutInflater.from(context);
		this.listGame = games;
	}
	
	@Override
	public int getCount() {
		return listGame.size();
	}

	@Override
	public Object getItem(int position) {
		return listGame.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		
		View ligne = lInflater.inflate(R.layout.activity_games, parent, false);

		((TextView) ligne.findViewById(R.id.textDateAndCompeteName)).setText("Compétition : " + listGame.get(position).getCompetname());
		((TextView) ligne.findViewById(R.id.textDateAndHeure)).setText("Le : " + listGame.get(position).getDate() + " à " + listGame.get(position).getHeure());
		((TextView) ligne.findViewById(R.id.textTeamAndScore)).setText("Equipes : " + listGame.get(position).getTeam1()+" ("+listGame.get(position).getScore1()+") - ("+listGame.get(position).getScore2()+") "+listGame.get(position).getTeam2());
		
		return ligne;
	}

}
